package com.twu.biblioteca.view;

import com.twu.biblioteca.model.Movie;

import java.util.List;

/**
 * Created by akutschm on 06/05/2014.
 */
public class MovieListView {

    public String render(List<Movie> movies) {
            String format = "%-4s %-20s %-32s %-18s %-20s";
            StringBuilder sb = new StringBuilder(String.format(format, "ID", "AUTHOR", "TITLE", "YEAR", "RATING").trim() + "\n");
            for (Movie movie : movies) {
                sb.append(String.format(format, movie.getId(), movie.getAuthor(), movie.getTitle(), movie.getYear(), movie.getRating()).trim());
                sb.append("\n");
            }
            return sb.toString().trim();
    }

}
